{template header}
{if $tips}
<div class="alert">{$tips}<a class="close" data-dismiss="alert" href="#">&times;</a></div>
{else}
<link rel="stylesheet" href="static/calendar/js/calendar.css" />
<script type="text/javascript" charset="utf-8" src="static/calendar/calendar.php"></script>
<link rel="stylesheet" href="static/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="static/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="static/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
    var editor;
    KindEditor.ready(function(K) {
      editor = K.create('textarea[name="content"]', {
        allowFileManager : true,
        uploadJson: './index.php?c=admin&a=uploadKindEditorImg',
        newlineTag:'p',
        filterMode : true,
        htmlTags:{
          p : ['style','color'],
          font : ['color', 'size', 'face'],
          span : ['style','color'],
          div : ['class', 'align'],
          a : ['class', 'href', 'target', 'name'],
          embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality',
          'style', 'align', 'allowscriptaccess', '/'],
          img : ['src', 'width', 'height', 'border', 'alt', 'title', 'align', 'style', '/'],
          hr : ['class', '/'],
          br : ['/'],
          'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : ['align'],
          'tbody,tr,strong,b,sub,sup,em,i,u,strike' : []
        }
      });
    });
    window.onload=function (){
        var a_channel = $("#a_channel").val();
        if(a_channel != ''){
            $("input#start_time_btn").attr("disabled", false);
            $("input#end_time_btn").attr("disabled", false);
        }else{
            $("input#start_time_btn").attr("disabled", true);
            $("input#end_time_btn").attr("disabled", true);
        }
  }
  $(document).ready(function(){
      $("select#a_channel").blur(function()
        {
          var a_channel = $(this).val();
          if(a_channel != ''){
            $("input#start_time_btn").attr("disabled", false);
            $("input#end_time_btn").attr("disabled", false);
        }else{
            $("input#start_time_btn").attr("disabled", true);
            $("input#end_time_btn").attr("disabled", true);
        }
        });
      $("span#addTag").click(function(){
          $("input#newTag").toggleClass("hide");
          $("span#subNewTag").toggleClass("hide");
      });
      $("input#resetStartTime").click(function(){
          $("input#starttimeid").val("1970-01-01 08:00:00");
      });
      $("span#subNewTag").click(function(e){
          tag = $("#newTag").val();
          $.ajax({url:"index.php?c=admin&a=addNewsTag&tag=" + tag,
                  async:false,
                  dataType:"json",
                  error:function(){
                      alert('未知错误');
                      },
                  success:function(data, status){
                    turnData = eval(data);
                    if(turnData.message == '')
                    {
                        tag = $("#newTag").val('');
                        tag = turnData.tag;
                        var option = document.createElement("option");
                        option.selected = "selected";
                        option.value = tag;
                        option.text = tag;
                        document.getElementById("tag-selector").appendChild(option);
                    }
                    else
                    {
                      alert(turnData.message);
                    }
                    $("input#newTag").toggleClass("hide");
                    $("span#subNewTag").toggleClass("hide");
                  }
              });
          return false;
      });
    });
</script>
<style type="text/css">
  label{float: left;margin: auto 10px;}
</style>
<form class="form-horizontal" action="index.php?c=admin&a=handlenews" method="post" enctype="multipart/form-data">
  <div class="control-group">
    <label class="control-label">评论用户数：</label>
    <div class="controls">
      <input type="text" disabled="disabled" value="{$detail['comment_user']}">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label">评论中新增用户数：</label>
    <div class="controls">
      <input type="text" disabled="disabled" value="{$detail['news_user']}">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputTiltle">资讯标题：</label>
    <div class="controls">
      <input type="text" name='title' placeholder="请输入资讯标题" value="{$detail['title']}">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">资讯简介：</label>
    <div class="controls">
      <textarea name="short_desc" placeholder="请输入资讯简介" style="min-width:80%; min-height:200x;">{$detail['short_desc']}</textarea>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">是否显示：</label>
    <div class="controls">
      <select name="is_show">
        <option value="1">是</option>
        <option {if $detail['is_show'] == 0} selected="selected" {/if} value="0">否</option>
      </select>
    </div>
  </div>
  <div class="control-group"><div class="controls">缩略图尺寸：214px X 160px</div></div>
  {loop $detail['thumb_img'] $k $img}
  <div class="control-group">
    <label class="control-label" for="inputThumbImg">缩略图：</label>
    <div class="controls">
      {if $img}
      <img src="{$img}" alt="缩略图">
      <!-- <img src="{$img}&time={eval echo time()}" alt="缩略图"> -->
      {/if}
      <input type="file" name="thumb_img_{$k}">
    </div>
  </div>
  {/loop}
  <div class="control-group">
    <label class="control-label" for="inputauthor">作者：</label>
    <div class="controls">
      <input type="text" name="author" placeholder="请输入资讯作者名字" value="{$detail['author']}">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputauthor">置顶：</label>
    <div class="controls">
      <label for="is_top_yes"><input type="radio" name="is_top" value="1" id="is_top_yes" {if $detail['is_top'] == 1} checked="checked"{/if}> 是</label>
      <label for="is_top_no"><input type="radio" name="is_top" value="0" id="is_top_no" {if $detail['is_top'] != 1} checked="checked"{/if}> 否</label>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputstarttime">开始显示时间：</label>
    <div class="controls">
      <input type="text" name="start_time" readonly="readonly" id="starttimeid" value="{eval echo date('Y-m-d H:i:s', $detail['start_time'])}">
      <input name="starttimebtn" type="button" id="starttimebtn" onclick="return showCalendar('starttimeid', '%Y-%m-%d %H:%M:%S', '24', false, 'starttimebtn');" value="选择" class="button" />
      <input type="button" class="button" value="归零" id="resetStartTime">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputtag">运营渠道：</label>
    <div class="controls">
      <select name="a_channel" id="a_channel">
        <option value="">非渠道运营文章</option>
        {loop $publishChannel $k $channel}
          <option value="{$k}" {if $detail['a_channel'] == $k} selected="seleted"{/if}>{$channel}</option>
        {/loop}
      </select>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputaddtime">设置活动期限：</label>
    <div class="controls">
      开始时间：<input type="text" name="a_start_time" readonly="readonly" id="start_time_id" value="{eval echo date('Y-m-d H:i', $detail['a_start_time'])}">
      <input name="start_time_btn" type="button" id="start_time_btn" onclick="return showCalendar('start_time_id', '%Y-%m-%d %H:%M', '24', false, 'start_time_btn');" value="选择" class="button" id="start_time_id"/>
      结束时间：<input type="text" name="a_end_time" readonly="readonly" id="end_time_id" value="{eval echo date('Y-m-d H:i', $detail['a_end_time'])}">
      <input name="end_time_btn" type="button" id="end_time_btn" onclick="return showCalendar('end_time_id', '%Y-%m-%d %H:%M', '24', false, 'end_time_btn');" value="选择" class="button" id="end_time_id"/>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputaddtime">设置添加时间：</label>
    <div class="controls">
      <input type="text" name="add_time" readonly="readonly" id="add_time_id" value="{eval echo date('Y-m-d H:i:s', $detail['add_time'])}">
      <input name="add_time_btn" type="button" id="add_time_btn" onclick="return showCalendar('add_time_id', '%Y-%m-%d %H:%M:%S', '24', false, 'add_time_btn');" value="选择" class="button" id="add_time_id"/>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">
      资讯内容：<font color="blue"><br>如有图片<br>图片宽度<br>不应小于<br><strong>640px</strong><br></font>
    </label>
    <div class="controls">
      <textarea name="content" style="width:800px;height:400px;">{$detail['content']}</textarea>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputtag">资讯标签：</label>
    <div class="controls">
      <select name="tag" id="tag-selector">
        <option value="">请输入资讯标签</option>
        {loop $tags $k $tag}
        <option value="{$tag}" {if $detail['tag'] == $tag}selected="selected"{/if}>{$tag}</option>
        {/loop}
      </select>
      <span id="addTag" class="btn">标签太少不够耍?点这里</span>
      <input id="newTag" class="newTag hide" placeholder="新标签">
      <span id="subNewTag" class="btn hide">添加</span>
    </div>
  </div>
     <div class="control-group">
    <div class="controls">
        <input type="hidden" name="news_id" value="{$detail['news_id']}">
        {if $handletype == 'add'}
          <input type="hidden" name="handletype" value="insert">
        {elseif $handletype == 'edit'}
          <input type="hidden" name="handletype" value="update">
        {/if}
        <button type="submit" class="btn">提交</button>
    </div>
  </div>
</form>
{/if}
{template footer}